﻿Imports System.Data
Imports System.Data.SqlClient

Public Class DangKyDAO
    Private dataProvider As DataProvider
    Private sqlstr As String
    Public Sub New()
        dataProvider = New DataProvider
    End Sub
    Public Shared Function GetData() As DataTable
        Dim dt As DataTable = dataProvider.Executequery("sp_XuatSV")
        Return dt
    End Function


    Public Shared Sub ThemSVDK(ByVal dk As DangKyDTO)
        Dim cn As SqlConnection = dataProvider.GetConnection()
        cn.Open()
        Dim cmd As SqlCommand = New SqlCommand("sp_ThemSinhVien")
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Parameters.Add("@MaSinhVien", SqlDbType.VarChar, 10)
        cmd.Parameters.Add("@MaMonHocMo", SqlDbType.Int)
        cmd.Parameters.Add("@NgayDK", SqlDbType.DateTime)

        cmd.Parameters("@MaSinhVien").Value = dk.MaSinhVien
        cmd.Parameters("@MaMonHocMo").Value = dk.MaMonHocMo
        cmd.Parameters("@NgayDK").Value = dk.NgayDK

        cmd.ExecuteNonQuery()
        cn.Close()
    End Sub

    Public Function DeleteCustomer(ByVal qlDKDTO As DangKyDTO)
        Dim maSV As String = qlDKDTO.MaSinhVien
        sqlstr = "DELETE Customer WHERE CustomerId='" & maSV & "'"
        Return dataProvider.Excute(sqlstr)
    End Function
End Class
